<template>
  <div>
    <Card>
      <span v-if="radioGroup">
        <div class="title">单选题</div>
        <div class="question" v-for="(item,index) in radioGroup" :key="index">
          <div class="questionTitle">{{index+1}}.{{item.questiondetail}}</div>
          <RadioGroup vertical style="padding-left:20px">
            <Radio label="1" v-if="item.a">
              <span class="questionOption">A.{{item.a}}</span>
            </Radio>
            <Radio label="2" v-if="item.b">
              <span class="questionOption">B.{{item.b}}</span>
            </Radio>
            <Radio label="3" v-if="item.c">
              <span class="questionOption">C.{{item.c}}</span>
            </Radio>
            <Radio label="4" v-if="item.d">
              <span class="questionOption">D.{{item.d}}</span>
            </Radio>
            <Radio label="4" v-if="item.e">
              <span class="questionOption">E.{{item.e}}</span>
            </Radio>
            <Radio label="4" v-if="item.f">
              <span class="questionOption">F.{{item.f}}</span>
            </Radio>
            <Radio label="4" v-if="item.g">
              <span class="questionOption">G.{{item.g}}</span>
            </Radio>
          </RadioGroup>
        </div>
      </span>
      <span v-if="multipleGroup">
        <div class="title">多选题</div>
        <div class="question" v-for="(item,index) in multipleGroup" :key="index">
          <div class="questionTitle">{{index+1}}.{{item.questiondetail}}</div>
          <CheckboxGroup style="padding-left:20px">
            <Checkbox label="1" v-if="item.a">
              <span class="questionOption">A.{{item.a}}</span>
            </Checkbox>
            <br />
            <Checkbox label="2" v-if="item.b">
              <span class="questionOption">B.{{item.b}}</span>
            </Checkbox>
            <br />
            <Checkbox label="3" v-if="item.c">
              <span class="questionOption">C.{{item.c}}</span>
            </Checkbox>
            <br />
            <Checkbox label="4" v-if="item.d">
              <span class="questionOption">D.{{item.d}}</span>
            </Checkbox>
            <br />
            <Checkbox label="5" v-if="item.e">
              <span class="questionOption">E.{{item.e}}</span>
            </Checkbox>
            <br />
            <Checkbox label="6" v-if="item.f">
              <span class="questionOption">F.{{item.f}}</span>
            </Checkbox>
            <br />
            <Checkbox label="7" v-if="item.g">
              <span class="questionOption">G.{{item.g}}</span>
            </Checkbox>
          </CheckboxGroup>
        </div>
      </span>
      <span v-if="judgeGroup">
        <div class="title">判断题</div>
        <div class="question" v-for="(item,index) in judgeGroup" :key="index">
          <div class="questionTitle">{{index+1}}.{{item.questiondetail}}</div>
          <RadioGroup vertical style="padding-left:20px">
            <Radio label="1" v-if="item.a">
              <span class="questionOption">A.{{item.a}}</span>
            </Radio>
            <Radio label="2" v-if="item.b">
              <span class="questionOption">B.{{item.b}}</span>
            </Radio>
            <Radio label="3" v-if="item.c">
              <span class="questionOption">C.{{item.c}}</span>
            </Radio>
            <Radio label="4" v-if="item.d">
              <span class="questionOption">D.{{item.d}}</span>
            </Radio>
            <Radio label="4" v-if="item.e">
              <span class="questionOption">E.{{item.e}}</span>
            </Radio>
            <Radio label="4" v-if="item.f">
              <span class="questionOption">F.{{item.f}}</span>
            </Radio>
            <Radio label="4" v-if="item.g">
              <span class="questionOption">G.{{item.g}}</span>
            </Radio>
          </RadioGroup>
        </div>
      </span>
      <div style="text-align:center">
        <Button type="primary" @click="back">返回</Button>
      </div>
    </Card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      trainid: this.$route.query.trainid,
      obj: this.$route.query.obj,
      radioGroup: "",
      multipleGroup: "",
      judgeGroup: ""
    };
  },
  methods: {
    // 返回
    back() {
      this.$router.replace({
        name: "publishExam",
        query: {
          mark: "back",
          obj: this.obj
        }
      });
    },

    // 初始化
    initial() {
      this.api.selectTrainTemplate({ trainid: this.trainid }).then(res => {
        if (res.code == 200 && res.data != null) {
          if (
            res.data.uerTrainQuestionOneVO &&
            res.data.uerTrainQuestionOneVO.length > 0
          ) {
            this.radioGroup = res.data.uerTrainQuestionOneVO;
          }
          if (
            res.data.uerTrainQuestionMoreVO &&
            res.data.uerTrainQuestionMoreVO.length > 0
          ) {
            this.multipleGroup = res.data.uerTrainQuestionMoreVO;
          }
          if (
            res.data.uerTrainQuestionJudgeVO &&
            res.data.uerTrainQuestionJudgeVO.length > 0
          ) {
            this.judgeGroup = res.data.uerTrainQuestionJudgeVO;
          }
        }
      });
    }
  },
  mounted() {
    this.initial();
  },
  beforeDestroy() {
    this.trainid = null
    this.obj = null
    this.radioGroup = null
    this.multipleGroup = null
    this.judgeGroup = null
  },
};
</script>
<style scoped lang="less">
@import "./index";
</style>

<style>
.ivu-checkbox-group-item {
  margin-bottom: 10px;
}
</style>